<?php
session_start();
isLogin();

if(isset($_POST["Submits"])){
	$fields=array('h_name','h_style');
	checkNotNull($fields,"?".$_SERVER['QUERY_STRING'],"类目");
	if($_REQUEST['act']=='modify'){
		$sql=getUpdateSql($fields,'haodiantype'," where h_id=".$_REQUEST['h_id']);
		$pre="修改";
	}else{
		$sql=getInsertSql($fields,"haodiantype");
		$pre="添加";
	}
	if(mysql_query($sql)){
		reload_js($pre."成功","index.php?cmd=haodiantype");
	}else{
		reload_js($pre."失败，原因：程序错误，请联系技术人员进行修改","index.php");
	}
}

$arr="";
if($_REQUEST['act']=='modify'){
	$arr=get_list_by_id('haodiantype','h_id',$_REQUEST['h_id']);
	if(!$arr){
		reload_js("错误的参数s_id","?cmd=haodiantype");
	}
}else if($_REQUEST['act']=='del'){
	$sql="delete from ".$prefix."haodiantype where h_id=".$_GET['h_id'];
	$pre="删除";
	if(mysql_query($sql)){
		reload_js($pre."成功",$_SERVER['HTTP_REFERER']);
	}else{
		reload_js($pre."失败，原因：程序错误，请联系技术人员进行修改","index.php");
	}
}
?>
<script language="javascript" src="../templates/<?php echo $moban;?>/js/common.js"></script>
<script language="javascript">
changeWebTitle('淘宝好店推荐类目管理');
</script>
<style type="text/css">
.header1 {background-color: #ebffe0; border: 1px solid #d9fec8;}
.header2 {background-color: #FFE6E7; border: 1px solid #FCE4E4;}
.header3 {background-color: #F5E4EE; border: 1px solid #ebd1de;}
.header4 {background-color: #FFE6FF; border: 1px solid #FFD7FF;}
.header5 {background-color: #E5F2E3; border: 1px solid #d6e9d5;}
.header6 {background-color: #FDEED9; border: 1px solid #f8e4c3;}
</style>
<div class="ContentRight">
    <div class="ContentRightTop">
      <div class="BarLeft"></div>
      <div class="ContentRightTopText">淘宝好店推荐类目管理
	  <?php 
	  if($_GET['act']==''){
	  	echo '<a href="?cmd='.$_REQUEST['cmd'].'&amp;act=add">（点此添加类目）</a>';
	  }else{
	  	echo "<a href='".$_SERVER['HTTP_REFERER']."'>（返回）</a>";
	  }
	  ?>
	  </div>
      <div class="BarRight"></div>
      <div class="Cal"></div>
    </div>
  <div class="ContentRightBox">
	<?php if($_REQUEST['act']==''){?>
<table width="100%" cellpadding="0" class="Table1" bordercolor="#4ab902" border="1" cellspacing="0">
        
        <tr>
          <td width="18%" align="center">ID</td>
          <td width="51%" height="25" align="center">类别名称</td>
          <td width="13%" align="center">类别样式</td>
          <td width="18%" align="center">操作</td>
        </tr>
		<?php 
		$page=$_REQUEST['page']?$_REQUEST['page']:1;
		$pagesize=10;
		$sql="select * from ".$prefix."haodiantype order by h_id desc limit ".($page-1)*$pagesize.",".$pagesize;
		$result=mysql_query($sql);
		while($arr=mysql_fetch_array($result)){
		?>
		<tr>
          <td width="18%" align="center"><?php echo $arr['h_id']?></td>
          <td width="51%" height="25" align="center"><?php echo $arr['h_name']?></td>
          <td width="13%" align="center"><?php echo $arr['h_style']?></td>
          <td width="18%" align="center"><a href="<?php echo "?cmd=".$_REQUEST['cmd']."&h_id=".$arr['h_id']."&act=modify"?>">修改</a>&nbsp;<a href="<?php echo "?cmd=".$_REQUEST['cmd']."&h_id=".$arr['h_id']."&act=del"?>" onclick="return confirm('您确认删除该条记录？删除后将不可恢复！');">删除</a></td>
        </tr>
		<?php
		}
		?>
        <tr>
          <td height="25" colspan="4" align="center">
		  <?php 
		  pagefy(get_list_count('haodiantype',$sqladd),$pagesize,'');
		  echo $pagenav;
		  ?>		  </td>
        </tr>
        <tr>
          <td height="25" align="right">版权所有：</td>
          <td colspan="3"><a href="http://www.fengsh8.com" target="_blank">风尚淘客程序</a></td>
        </tr>
      </table>
    <?php }else{?>
	  <form action="" name="productform" method="post">
    <table width="100%" cellpadding="0" class="Table1" bordercolor="#4ab902" border="1" cellspacing="0">
        <tr>
          <td width="22%" height="25" align="right">类目名称：</td>
          <td width="78%"><input name="h_name" type="text" id="h_name" value="<?php echo $arr['h_name'];?>" size="25"/></td>
        </tr>
        <tr>
          <td height="25" align="right">店铺样式：</td>
          <td>
		   <select name="h_style" id="h_style" style="float:left" onChange="document.getElementById('h_style_span').className=this.value;">
		   <option value="header1" <?php if($arr['h_style']=='header1'){echo "selected";}?>>header1</option>
		   <option value="header2" <?php if($arr['h_style']=='header2'){echo "selected";}?>>header2</option>
		   <option value="header3" <?php if($arr['h_style']=='header3'){echo "selected";}?>>header3</option>
		   <option value="header4" <?php if($arr['h_style']=='header4'){echo "selected";}?>>header4</option>
		   <option value="header5" <?php if($arr['h_style']=='header5'){echo "selected";}?>>header5</option>
		   <option value="header6" <?php if($arr['h_style']=='header6'){echo "selected";}?>>header6</option>
		  </select>
		  <span id="h_style_span" class="<?php echo $arr['h_style'];?>" style="float:left; margin-left:10px;width:100px; height:16px; display:block"></span>		  
		  </td>
        </tr>
        <tr>
          <td height="25" align="right">&nbsp;</td>
          <td><input name="Submits" type="submit" id="Submits" value=" 提  交" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input name="Reset" type="reset" id="Reset" value=" 重 置 " />          </td>
        </tr>
      </table>
	  </form>
    <?php }?>
  </div>
    <div class="Cal"></div>
  </div>